
class TagCurMenu {


    static updateTagCurMenu(vm, item) {
        vm.$router.push({ path: item.path })

        let curMenuList = TagCurMenu.handlerObjConvertAry(item)

        vm.$store.commit('updateCurMenuList', curMenuList)


        vm.$store.commit('updateTagList', item)
    }


    static deleteTagAndUpdateCurMenu(vm, tag) {
        let oTagList = vm.$store.state.tagList
        let activeIndex = null
        oTagList.forEach((item, index) => {

            if (item.path == tag.path) {
                activeIndex = index
            }
        })

        vm.$store.commit('removeTag', tag.path)
        let nTagList = vm.$store.state.tagList
        vm.$router.push({ path: nTagList[activeIndex - 1].path })

        let curMenuList = TagCurMenu.handlerObjConvertAry(nTagList[activeIndex - 1])
        vm.$store.commit('updateCurMenuList', curMenuList)
    }


    static handlerObjConvertAry(item) {
        let ary = []
        item.parent ? ary.push({ ...item.parent }) : {}
        ary.push({ ...item })
        return ary
    }


}

export { TagCurMenu }